import { Module } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { getConnectionOptions } from 'typeorm'
import { UserModule } from './user/user.module'
import { HomeModule } from './home/home.module'
import { CategoryModule } from './category/category.module'
import { CartModule } from './cart/cart.module'
import { OrderModule } from './order/order.module'
import { join } from 'path'
import { ServeStaticModule } from '@nestjs/serve-static'

@Module({
  imports: [
    // 注入TypeORM模块
    TypeOrmModule.forRootAsync({
      useFactory: async () =>
        Object.assign(await getConnectionOptions(), {
          autoLoadEntities: true,
        }),
    }),
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, 'uploads'),
      // renderPath:'a',// 虚拟路径【uploads文件下创建a文件】【基本不用】
    }),
    UserModule,
    HomeModule,
    CategoryModule,
    CartModule,
    OrderModule,
  ],
})
export class AppModule {}
